2020-2021 Sunseeker Telemetry and Lighting System
tlv_ex2_readTLVDescriptors.c
Go to the documentation of this file.
1 /* --COPYRIGHT--,BSD
2  * Copyright (c) 2017, Texas Instruments Incorporated
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  *
16  * * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  * --/COPYRIGHT--*/
32 //******************************************************************************
56 //*****************************************************************************
57 
58 #include "driverlib.h"
59 
60 // Die Record Variables
61 struct s_TLV_Die_Record * pDIEREC;
63 uint16_t temp;
64 uint32_t WaferID;
65 uint16_t DieX, DieY, TestRes;
66 
67 // ADC Variables
68 struct s_TLV_ADC_Cal_Data * pADCCAL;
69 uint8_t bADCCAL_bytes;
70 uint16_t ADCGain, ADCOffset;
73 
74 // REF Variables
75 struct s_TLV_REF_Cal_Data * pREFCAL;
76 uint8_t bREFCAL_bytes;
77 uint16_t REF_15V, REF_20V, REF_25V;
78 
79 // Peripheral Variables
80 struct s_Peripheral_Memory_Data * pPeriph;
81 uint8_t bPeriph_bytes;
83 uint16_t PMM_Exist;
84 
85 void readDieRecord(void);
86 void readADCCAL(void);
87 void readREFCAL(void);
88 void readPeripheral(void);
89 
90 void main(void)
91 {
92  //Stop WDT
93  WDT_A_hold(WDT_A_BASE);
94 
95  readDieRecord();
96  readADCCAL();
97  readREFCAL();
99 
100  // Place breakpoint here
101  while(1);
102 }
103 
104 //******************************************************************************
105 //
106 // This function will search the TLV block for the Die Record tag and store the
107 // address of the first data in the block in the reference pointer passed as an
108 // argument. The data is then saved to local variables.
109 //
110 //******************************************************************************
111 
112 void readDieRecord(void)
113 {
114  // Read Die Record Values
115  TLV_getInfo(TLV_TAG_DIERECORD,
116  0,
118  (uint16_t **)&pDIEREC
119  );
120 
121  WaferID = pDIEREC->wafer_id;
122  DieX = pDIEREC->die_x_position;
123  DieY = pDIEREC->die_y_position;
124  TestRes = pDIEREC->test_results;
125 }
126 
127 //******************************************************************************
128 //
129 // This function will search the TLV block for the ADC CAL tag and store the
130 // address of the first data in the block in the reference pointer passed as an
131 // argument. The data is then saved to local variables.
132 //
133 //******************************************************************************
134 
135 void readADCCAL(void)
136 {
137  // Read ADC12 Calibration Values
138  TLV_getInfo(TLV_TAG_ADCCAL,
139  0,
140  &bADCCAL_bytes,
141  (uint16_t **)&pADCCAL
142  );
143 
144  ADCGain = pADCCAL->adc_gain_factor;
145  ADCOffset = pADCCAL->adc_offset;
146  ADC_15V_Ref_30C = pADCCAL->adc_ref15_30_temp;
147  ADC_15V_Ref_85C = pADCCAL->adc_ref15_85_temp;
148  ADC_20V_Ref_30C = pADCCAL->adc_ref20_30_temp;
149  ADC_20V_Ref_85C = pADCCAL->adc_ref20_85_temp;
150  ADC_25V_Ref_30C = pADCCAL->adc_ref25_30_temp;
151  ADC_25V_Ref_85C = pADCCAL->adc_ref25_85_temp;
152 }
153 
154 //******************************************************************************
155 //
156 // This function will search the TLV block for the REF CAL tag and store the
157 // address of the first data in the block in the reference pointer passed as an
158 // argument. The data is then saved to local variables.
159 //
160 //******************************************************************************
161 
162 void readREFCAL(void)
163 {
164  // Read REF Calibration Values
165  TLV_getInfo(TLV_TAG_REFCAL,
166  0,
167  &bREFCAL_bytes,
168  (uint16_t **)&pREFCAL
169  );
170 
171  REF_15V = pREFCAL->ref_ref15;
172  REF_20V = pREFCAL->ref_ref20;
173  REF_25V = pREFCAL->ref_ref25;
174 }
175 
176 //******************************************************************************
177 //
178 // The function checks for the existence of memory blocks in a device.
179 // This is followed by checking if the PMM module exists and is defined in the
180 // peripheral descriptor section.
181 //
182 // The function TLV_getInfo searches the TLV block for the Peripheral tag and
183 // stores the address of the first data in the block in the reference pointer
184 // passed as an argument. The data is then saved to local variables.
185 //
186 // The function Get_TLV_peripheral returns a non-zero value indicating the PMM
187 // peripheral exists TLV_getPeripheral the current device. This same procedure can be
188 // replicated for any peripheral that is listed in the device datasheet. The
189 // tag code that corresponds to each peripheral can be found in tlv.h
190 
191 //******************************************************************************
192 
193 void readPeripheral(void)
194 {
195  // Read Peripheral Memory Descriptors
196  TLV_getInfo(TLV_TAG_PDTAG,
197  0,
198  &bPeriph_bytes,
199  (uint16_t **)&pPeriph
200  );
201 
202  Memory_1 = pPeriph->memory_1;
203  Memory_2 = pPeriph->memory_2;
204  Memory_3 = pPeriph->memory_3;
205  Memory_4 = pPeriph->memory_4;
206 
207  // Read PMM Descriptor to Show its Availability
208  PMM_Exist = TLV_getPeripheral(TLV_PID_PMM, 0);
209 }
uint16_t ADC_20V_Ref_85C
void readDieRecord(void)
uint8_t bPeriph_bytes
uint16_t ADC_20V_Ref_30C
uint16_t temp
uint16_t DieX
void readADCCAL(void)
uint16_t ADC_25V_Ref_30C
void main(void)
uint16_t Memory_2
uint8_t bADCCAL_bytes
uint16_t REF_25V
uint16_t TestRes
uint16_t ADCGain
struct s_TLV_Die_Record * pDIEREC
struct s_Peripheral_Memory_Data * pPeriph
void readREFCAL(void)
uint16_t REF_20V
uint16_t Memory_1
uint16_t Memory_3
uint16_t PMM_Exist
uint16_t ADCOffset
uint16_t Memory_4
uint16_t ADC_15V_Ref_85C
uint8_t bREFCAL_bytes
void readPeripheral(void)
uint32_t WaferID
uint16_t ADC_25V_Ref_85C
struct s_TLV_ADC_Cal_Data * pADCCAL
uint16_t ADC_15V_Ref_30C
uint8_t bDieRecord_bytes
struct s_TLV_REF_Cal_Data * pREFCAL
uint16_t REF_15V
uint16_t DieY